package egs.clone;

public class deep implements Cloneable {
	 
    int a = 10;
    StringBuffer b = new StringBuffer("abc");
 
    protected Object clone() throws CloneNotSupportedException {
        return new deep();
    }
 
    public static void main(String[] args) {
        deep b1 = new deep();
        try {
            deep b2 = (deep)b1.clone();
            System.out.println("Before");
            System.out.println("b1.a=" + b1.a + " b1.b=" + b1.b);
            System.out.println("b2.a=" + b2.a + " b2.b=" + b2.b);
            b1.a=20;
            b1.b.append("def");
            System.out.println("After");
            System.out.println("b1.a=" + b1.a + " b1.b=" + b1.b);
            System.out.println("b2.a=" + b2.a + " b2.b=" + b2.b);
        }
     
 catch (CloneNotSupportedException e) {
         e.printStackTrace();
        }
    }
}

